package com.gimi.cloud.jimi.client.controller.moreInfo;

import com.gimi.cloud.jimi.common.enums.ResponseCodeEnum;
import com.gimi.cloud.jimi.common.enums.common.RedisKeyEnum;
import com.gimi.cloud.jimi.common.mq.service.MqCommonSenderService;
import com.gimi.cloud.jimi.common.utils.reqhead.Util;
import com.gimi.cloud.jimi.commonService.InterfacePlatform.impl.InterfaceUtil;
import com.gimi.cloud.jimi.dao.redis.IRedisService;
import com.gimi.cloud.jimi.dto.params.TaobaoParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @auther loongs
 * @date 2018/1/11  16:40
 */
@RestController
@RequestMapping("/moreInfo")
public class TaobaoController {
    private final static String redisKey = RedisKeyEnum.JIMI_CONFIG_PRE.getKey() + "interface_platform_universal_taoBao";

    private InterfaceUtil interfaceUtil;
    private MqCommonSenderService commonSenderService;
    private IRedisService iRedisService;

    @Autowired
    public TaobaoController(InterfaceUtil interfaceUtil, MqCommonSenderService commonSenderService, IRedisService iRedisService) {
        this.interfaceUtil = interfaceUtil;
        this.commonSenderService = commonSenderService;
        this.iRedisService = iRedisService;
    }

    /**
     * 获取登录参数
     */
    @RequestMapping("/taobaoLogin")
    public void taobaoLogin(@RequestBody TaobaoParams taobaoParams, HttpServletResponse response) {
        taobaoParams.setRedisKey(redisKey);
        taobaoParams.setInterfcaeParamKey("fengchaotaobaologin");
        taobaoParams.setInterfcaeResultKey("check");
        Util.sendResponseFastJson(interfaceUtil.call(taobaoParams), ResponseCodeEnum.SUCCESSED, response);
    }
}
